﻿using System;

namespace ggdll.GGMessages.Outgoing
{
    class GGMessageContactListRequest
    {
        private static int message_type=(int)GGMessageType.GG_USERLIST100_REQUEST;
        private int message_size;
        public byte type;		/* rodzaj zapytania */
	    public int version;		/* numer ostatniej znanej wersji listy kontaktów bądź 0 */
	    public byte format_type;	/* rodzaj formatu listy kontaktów */
	    public byte unknown1=0x01;		/* zawsze 0x01 */
	    public string request="";		/* treść (nie musi wystąpić) */

        public byte[] getBytes()
        {
            message_size = 7 + request.Length;
            byte[] response = new byte[message_size + 8];
            System.Buffer.BlockCopy(BitConverter.GetBytes(message_type), 0, response, 0, 4); // Header
            System.Buffer.BlockCopy(BitConverter.GetBytes(message_size), 0, response, 4, 4); // Header

            System.Buffer.BlockCopy(BitConverter.GetBytes(type), 0, response, 8, 1); // typ

            System.Buffer.BlockCopy(BitConverter.GetBytes(version), 0, response, 9, 4); // wersja

            System.Buffer.BlockCopy(BitConverter.GetBytes(format_type), 0, response, 13, 1); // format
            System.Buffer.BlockCopy(BitConverter.GetBytes(unknown1), 0, response, 14, 1); // ?

            System.Buffer.BlockCopy(StaticVars.enc.GetBytes(request), 0, response, 14, request.Length); // request

            return response;
        }
    }
}
